#coding:utf-8
import getpass
import login

class Pwd:
    def __init__(self):
        pass

    def add_Pwd(self):
        Flag = 1
        while Flag:
            tag = raw_input('请输入你需要添加密码的类型：')
            for i in login.tags_type:
                if i.get('tag') == tag:
                    print '请输入以下密码项目,',i['items'],':',
                    item = raw_input()
                    dict={'tag':tag}
                    item_each = item.split(',')
                    for j in range(len(i['items'])):
                        dict[i['items'][j]]=item_each[j]
                    _password_list.append(dict)
                    print _password_list
                    Flag = 0
                    break
            else:
                continue
            #print password_item
    def updata_Pwd(self):
        Flag = 1
        while Flag:
            title = raw_input('请输入你需要修改密码的title：')
            accounts = raw_input('请输入你需要修改密码的accounts：')
            for i in _password_list:
                if i.get('accounts') == accounts:
                    password = raw_input('请输入你要修改的密码')
                    i['password'] = password
                    print _password_list
                    Flag = 0
                    break
            else:
                print 'title或accounts 不存在，请重新输入'
                continue


    def delete_Pwd(self):
        Flag = 1
        while Flag:
            tag = raw_input('请输入你需要删除的密码的tag：')
            title = raw_input('请输入你需要删除的密码的title：')
            accounts = raw_input('请输入你需要删除的密码的accounts：')
            for i in _password_list:
                if i.get('tag') == tag and i.get('title') == title and i.get('accounts') == accounts:
                    _password_list.remove(i)
                    print _password_list
                    Flag = 0
                    break
            else:
                continue
